<template>
  <div
    class="kanban-girl-cs"
    :class="{ expanded: isExpanded }"
    :style="{
      bottom: bottomPosition,
      right: rightPosition,
      left: leftPosition,
    }"
  >
    <!-- 看板娘角色区域 -->
    <div
      class="kanban-character"
      :class="{ active: isHovered, animated: isAnimated, breathe: isBreathing }"
      :style="{
        height: characterHeight,
        width: characterWidth,
        transform: `translateY(${characterY}) rotate(${characterRotation}deg)`,
      }"
      @click="toggleExpand"
      @mouseenter="onMouseEnter"
      @mouseleave="onMouseLeave"
      ref="character"
    >
      <!-- 角色图像 -->
      <img
        :src="characterImg"
        alt="客服"
        class="character-img"
        @load="startBreathing"
      />

      <!-- 未读消息提示 -->
      <div v-if="unreadCount > 0" class="unread-badge bounce-in">
        <span>{{ unreadCount > 99 ? "99+" : unreadCount }}</span>
      </div>

      <!-- 对话气泡 -->
      <div v-if="showSpeechBubble" class="speech-bubble slide-in-top">
        <div class="speech-content">{{ speechText }}</div>
      </div>
    </div>

    <!-- 聊天窗口 -->
    <div
      class="chat-window"
      :class="windowTheme"
      :style="{
        width: windowWidth,
        height: windowHeight,
      }"
      v-show="isExpanded"
    >
      <!-- 窗口头部 -->
      <div class="window-header">
        <img :src="customerImg" alt="头像" class="header-avatar" />
        <div class="header-left">
          <div class="header-info">
            <h3 class="header-title">{{ serviceName }}</h3>
            <span class="header-status">{{ onlineStatus }}</span>
          </div>
          <div
            style="
              font-variation-settings: 'opsz' auto;
              font-feature-settings: 'kern' on;
              color: #26426c !important;
              font-size: 20px;
              font-weight: bold;
              padding-left: 50px;
            "
          >
            智能客服-小微 | 专门为您提供公众号咨询服务!
          </div>
        </div>
        <div class="header-right">
          <button
            class="minimize-btn"
            @click.stop="minimizeWindow"
            :title="'最小化'"
          >
            <i class="el-icon-minus"></i>
          </button>
          <button class="close-btn" @click.stop="toggleExpand" :title="'关闭'">
            <i class="el-icon-close"></i>
          </button>
        </div>
      </div>

      <!-- 聊天内容区域 -->
      <div class="chat-area" ref="chatArea">
        <!-- 欢迎消息 -->
        <div class="message message-system fade-in">
          <div class="message-content">{{ welcomeMessage }}</div>
        </div>

        <!-- 消息列表 -->
        <div
          v-for="(msg, index) in messages"
          :key="index"
          class="message"
          :class="`message-${msg.sender}`"
          :style="{ animationDelay: `${index * 0.1}s` }"
        >
          <img
            v-if="msg.sender === 'user'"
            :src="userAvatar"
            alt="用户头像"
            class="message-avatar"
          />
          <img
            v-else
            :src="customerImg"
            alt="客服头像"
            class="message-avatar"
          />
          <div class="message-content">
            {{ msg.content }}
            <span v-if="msg.time" class="message-time">{{ msg.time }}</span>
          </div>
        </div>

        <!-- 打字中提示 -->
        <div v-if="isTyping" class="typing-indicator">
          <span></span>
          <span></span>
          <span></span>
        </div>
      </div>

      <!-- 输入区域 -->
      <div class="input-area">
        <textarea
          v-model="inputMessage"
          placeholder="请输入您的咨询内容(如问题, 需求)"
          rows="2"
          @keyup.enter.ctrl="sendMessage"
          class="message-input"
        ></textarea>
        <div class="input-actions">
          <button class="emoji-btn" @click.stop="toggleEmojiPicker" title="">
            <i class="el-icon-smile"></i>表情
          </button>
          <button
            class="send-btn"
            @click="sendMessage"
            :disabled="!inputMessage.trim()"
            title=""
          >
            <i class="el-icon-paper-plane"></i>发送(Ctrl+Enter)
          </button>
        </div>

        <!-- 表情选择器 -->
        <div v-if="showEmojiPicker" class="emoji-picker slide-down">
          <div
            v-for="emoji in emojis"
            :key="emoji"
            class="emoji-item"
            @click="selectEmoji(emoji)"
            @mouseenter="$event.target.classList.add('emoji-item-hover')"
            @mouseleave="$event.target.classList.remove('emoji-item-hover')"
          >
            {{ emoji }}
          </div>
        </div>
      </div>
    </div>

    <!-- 快捷操作按钮 -->
    <div v-if="showQuickActions && !isExpanded" class="quick-actions">
      <button
        v-for="(action, index) in quickActions"
        :key="index"
        class="action-btn"
        :title="action.title"
        @click="performQuickAction(action)"
        :style="{ animationDelay: `${index * 0.1}s` }"
      >
        <i :class="action.icon"></i>
      </button>
    </div>
  </div>
</template>

<script>
export default {
  name: "KanbanGirlCustomerService",
  props: {
    // 服务名称
    serviceName: {
      type: String,
      default: "专属客服小助手",
    },

    // 欢迎消息
    welcomeMessage: {
      type: String,
      default: "您好！我是您的专属客服小微，有什么可以帮助您的吗？",
    },

    // 看板娘图片
    characterImg: {
      type: String,
      default: require("@/assets/home/admin/home/customer_service.png"),
    },
    // 客服头像
    customerImg: {
      type: String,
      default: require("@/assets/home/admin/home/customer_avatar.png"),
    },

    // 用户头像
    userAvatar: {
      type: String,
      default: "https://picsum.photos/id/64/40/40",
    },

    // 未读消息数
    unreadCount: {
      type: Number,
      default: 0,
    },

    // 窗口宽度
    windowWidth: {
      type: String,
      default: "1000px",
    },

    // 窗口高度
    windowHeight: {
      type: String,
      default: "500px",
    },

    // 角色高度
    characterHeight: {
      type: String,
      default: "300px",
    },

    // 角色宽度
    characterWidth: {
      type: String,
      default: "550px",
    },

    // 底部定位
    bottomPosition: {
      type: String,
      default: "100px",
    },

    // 右侧定位
    rightPosition: {
      type: String,
      default: "0",
    },

    // 左侧定位（默认不设置，优先右侧）
    leftPosition: {
      type: String,
      default: "200px",
    },

    // 窗口主题
    windowTheme: {
      type: String,
      default: "theme-blue",
      validator: (value) => {
        return [
          "theme-blue",
          "theme-pink",
          "theme-purple",
          "theme-green",
        ].includes(value);
      },
    },

    // 快捷操作按钮
    quickActions: {
      type: Array,
      default: () => [
        { title: "帮助中心", icon: "el-icon-question" },
        { title: "意见反馈", icon: "el-icon-edit" },
        { title: "联系我们", icon: "el-icon-phone" },
      ],
    },

    // 是否显示快捷操作
    showQuickActions: {
      type: Boolean,
      default: true,
    },
  },

  data() {
    return {
      // 是否展开
      isExpanded: false,

      // 是否最小化
      isMinimized: false,

      // 是否悬停
      isHovered: false,

      // 是否动画
      isAnimated: false,

      // 是否呼吸效果
      isBreathing: false,

      // 角色Y轴位置
      characterY: "0px",

      // 角色旋转角度
      characterRotation: 0,

      // 输入消息
      inputMessage: "",

      // 消息列表
      messages: [],

      // 是否正在输入
      isTyping: false,

      // 是否显示表情选择器
      showEmojiPicker: false,

      // 是否显示对话气泡
      showSpeechBubble: false,

      // 对话气泡文本
      speechText: "",

      // 在线状态
      onlineStatus: "在线",

      // 动画计时器
      animationTimer: null,

      // 呼吸动画计时器
      breathingTimer: null,

      // 摇摆动画计时器
      swingTimer: null,

      // 表情列表
      emojis: [
        "😀",
        "😃",
        "😄",
        "😁",
        "😆",
        "😅",
        "😂",
        "🤣",
        "😊",
        "😇",
        "🙂",
        "🙃",
        "😉",
        "😌",
        "😍",
        "🥰",
        "😘",
        "😗",
        "😙",
        "😚",
        "😋",
        "😛",
        "😝",
        "😜",
        "🤪",
        "🤨",
        "🧐",
        "🤓",
        "😎",
        "🤩",
        "🥳",
      ],
    };
  },

  computed: {
    // 计算定位样式
    positionStyle() {
      return {
        bottom: this.bottomPosition,
        right: this.rightPosition,
        left: this.leftPosition,
      };
    },
  },

  methods: {
    // 切换展开/收起
    toggleExpand() {
      this.isExpanded = !this.isExpanded;
      this.isMinimized = false;

      if (this.isExpanded) {
        // 展开时显示角色动画
        this.startAnimation();
        this.startSwingAnimation();

        // 清空未读消息
        if (this.unreadCount > 0) {
          this.$emit("clearUnread");
        }

        // 滚动到底部
        this.$nextTick(() => {
          this.scrollToBottom();
        });
      } else {
        // 收起时隐藏表情选择器
        this.showEmojiPicker = false;
        this.stopSwingAnimation();
      }
    },

    // 最小化窗口
    minimizeWindow() {
      this.isMinimized = true;
      this.isExpanded = false;
      this.showEmojiPicker = false;
      this.stopSwingAnimation();
    },

    // 发送消息
    sendMessage() {
      const content = this.inputMessage.trim();
      if (!content) return;

      // 获取当前时间
      const now = new Date();
      const time = `${now.getHours().toString().padStart(2, "0")}:${now
        .getMinutes()
        .toString()
        .padStart(2, "0")}`;

      // 添加用户消息
      this.messages.push({
        sender: "user",
        content: content,
        time: time,
      });

      // 清空输入框
      this.inputMessage = "";

      // 滚动到底部
      this.scrollToBottom();

      // 触发消息发送事件
      this.$emit("messageSent", this.messages[this.messages.length - 1]);

      // 模拟客服正在输入
      this.isTyping = true;

      // 模拟客服回复
      setTimeout(() => {
        this.isTyping = false;

        // 根据用户消息生成回复
        const reply = this.generateReply(content);

        // 添加客服消息
        this.messages.push({
          sender: "service",
          content: reply,
          time: `${new Date()
            .getHours()
            .toString()
            .padStart(2, "0")}:${new Date()
            .getMinutes()
            .toString()
            .padStart(2, "0")}`,
        });

        // 滚动到底部
        this.scrollToBottom();

        // 触发消息接收事件
        this.$emit("messageReceived", this.messages[this.messages.length - 1]);
      }, 1500);
    },

    // 生成回复
    generateReply(content) {
      const replies = [
        "好的，我明白了，我会尽快为您处理！",
        "感谢您的咨询，这个问题我需要查询一下相关资料。",
        "您的问题很重要，我会优先为您解决。",
        "请问还有其他需要帮助的吗？",
        "这个问题我很了解，让我为您详细解答。",
        "非常感谢您的反馈，我们会不断改进服务质量。",
      ];

      // 根据关键词生成更智能的回复
      if (
        content.includes("帮助") ||
        content.includes("问题") ||
        content.includes("怎么")
      ) {
        return "您遇到了什么问题呢？请详细描述，我会尽力帮助您解决。";
      } else if (content.includes("谢谢") || content.includes("感谢")) {
        return "不客气，这是我应该做的！";
      } else if (content.includes("再见") || content.includes("拜拜")) {
        return "再见！如有需要，随时召唤我哦！";
      }

      // 随机返回一个回复
      return replies[Math.floor(Math.random() * replies.length)];
    },

    // 滚动到底部
    scrollToBottom() {
      this.$nextTick(() => {
        const chatArea = this.$refs.chatArea;
        if (chatArea) {
          chatArea.scrollTop = chatArea.scrollHeight;
        }
      });
    },

    // 切换表情选择器
    toggleEmojiPicker() {
      this.showEmojiPicker = !this.showEmojiPicker;
    },

    // 选择表情
    selectEmoji(emoji) {
      this.inputMessage += emoji;
    },

    // 执行快捷操作
    performQuickAction(action) {
      this.$emit("quickAction", action);
    },

    // 鼠标悬停
    onMouseEnter() {
      this.isHovered = true;
      this.startSwingAnimation();
      this.showRandomSpeech();
    },

    // 鼠标离开
    onMouseLeave() {
      this.isHovered = false;
      this.stopSwingAnimation();
    },

    // 开始角色动画
    startAnimation() {
      this.isAnimated = true;

      // 简单的上下浮动动画
      let position = 0;
      let direction = 1;

      this.animationTimer = setInterval(() => {
        position += direction * 5;
        this.characterY = `${position}px`;

        if (position > 10 || position < -10) {
          direction = -direction;
        }
      }, 200);

      // 5秒后停止动画
      setTimeout(() => {
        this.stopAnimation();
      }, 5000);
    },

    // 停止角色动画
    stopAnimation() {
      if (this.animationTimer) {
        clearInterval(this.animationTimer);
        this.animationTimer = null;
        this.characterY = "0px";
      }
      this.isAnimated = false;
    },

    // 开始呼吸动画
    startBreathing() {
      this.isBreathing = true;
      // CSS动画处理呼吸效果
    },

    // 开始摇摆动画
    startSwingAnimation() {
      let angle = 0;
      let direction = 0.5;

      this.swingTimer = setInterval(() => {
        angle += direction;
        this.characterRotation = angle;

        if (angle > 3 || angle < -3) {
          direction = -direction;
        }
      }, 100);
    },

    // 停止摇摆动画
    stopSwingAnimation() {
      if (this.swingTimer) {
        clearInterval(this.swingTimer);
        this.swingTimer = null;
        this.characterRotation = 0;
      }
    },

    // 显示随机对话气泡
    showRandomSpeech() {
      const speeches = [
        "嗨！需要帮助吗？",
        "今天过得怎么样？",
        "有什么可以为您服务的？",
        "我在这里随时为您服务哦！",
        "您好呀！(✧ω✧)",
        "有什么问题都可以问我哦~",
      ];

      this.speechText = speeches[Math.floor(Math.random() * speeches.length)];
      this.showSpeechBubble = true;

      setTimeout(() => {
        this.showSpeechBubble = false;
      }, 3000);
    },
  },

  mounted() {
    // 滚动到底部
    this.scrollToBottom();

    // 开始呼吸动画
    this.startBreathing();

    // 随机显示对话气泡
    this.speechTimer = setInterval(() => {
      if (!this.isExpanded && Math.random() > 0.7) {
        this.showRandomSpeech();
      }
    }, 30000);

    // 偶尔随机摇摆
    this.randomSwingTimer = setInterval(() => {
      if (!this.isExpanded && Math.random() > 0.8) {
        this.startSwingAnimation();
        setTimeout(() => this.stopSwingAnimation(), 2000);
      }
    }, 15000);
  },

  beforeDestroy() {
    // 清理计时器
    if (this.animationTimer) {
      clearInterval(this.animationTimer);
    }

    if (this.breathingTimer) {
      clearInterval(this.breathingTimer);
    }

    if (this.swingTimer) {
      clearInterval(this.swingTimer);
    }

    if (this.speechTimer) {
      clearInterval(this.speechTimer);
    }

    if (this.randomSwingTimer) {
      clearInterval(this.randomSwingTimer);
    }
  },
};
</script>

<style scoped>
.kanban-girl-cs {
  position: fixed;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 角色区域 */
.kanban-character {
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.kanban-character.active {
  transform: scale(1.05) translateY(0) rotate(0deg);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

.kanban-character.animated {
  animation: float 3s ease-in-out infinite;
}

.kanban-character.breathe {
  animation: breathe 4s ease-in-out infinite;
}

.character-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: all 0.1s ease;
  /* 增加图片大小，保持比例 */
  margin-bottom: -10px;
}

/* 未读消息徽章 */
.unread-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background-color: #ff4d4f;
  color: white;
  border-radius: 15px;
  min-width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(255, 77, 79, 0.3);
  z-index: 10;
}

/* 对话气泡 */
.speech-bubble {
  position: absolute;
  top: 150px;
  left: 50%;
  transform: translateX(-50%);
  background-color: white;
  padding: 10px 15px;
  border-radius: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  max-width: 200px;
  z-index: 10;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: white transparent transparent;
}

.speech-content {
  font-size: 14px;
  color: #333;
  text-align: center;
  font-weight: 500;
}

/* 聊天窗口 */
.chat-window {
  background-color: white;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  margin-right: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  overflow: hidden;
  animation: windowSlideIn 0.4s ease-out;
  margin-left: 75px;
}

/* 窗口主题 */
.chat-window.theme-blue {
  --primary-color: #348cf8;
  --hover-color: #66b1ff;
  --active-color: #3a8ee6;
  --gradient: linear-gradient(135deg, #348cf8 0%, #66b1ff 100%);
}

.chat-window.theme-pink {
  --primary-color: #ec4141;
  --hover-color: #ff6b6b;
  --active-color: #d83a3a;
  --gradient: linear-gradient(135deg, #ec4141 0%, #ff6b6b 100%);
}

.chat-window.theme-purple {
  --primary-color: #909399;
  --hover-color: #a6a9ad;
  --active-color: #82848a;
  --gradient: linear-gradient(135deg, #909399 0%, #a6a9ad 100%);
}

.chat-window.theme-green {
  --primary-color: #67c23a;
  --hover-color: #85ce61;
  --active-color: #5daf34;
  --gradient: linear-gradient(135deg, #67c23a 0%, #85ce61 100%);
}

/* 窗口头部 */
.window-header {
  background: var(--gradient);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-avatar {
  position: absolute;
  top: -95px;
  max-height: 140px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.5);
  animation: avatarPulse 3s infinite;
}

.header-title {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.header-status {
  font-size: 12px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 4px;
  color: #323232;
  font-weight: bold;
}

.header-status::before {
  content: "";
  width: 6px;
  height: 6px;
  background-color: #348cf8;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.header-right {
  display: flex;
  gap: 8px;
}

.minimize-btn,
.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.minimize-btn:hover,
.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* 聊天区域 */
.chat-area {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background-color: #f9f9f9;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-image: radial-gradient(
      circle at 10% 20%,
      rgba(64, 158, 255, 0.05) 0%,
      transparent 20%
    ),
    radial-gradient(
      circle at 80% 60%,
      rgba(64, 158, 255, 0.03) 0%,
      transparent 30%
    );
}

/* 滚动条样式 */
.chat-area::-webkit-scrollbar {
  width: 6px;
}

.chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
  background: rgba(150, 150, 150, 0.3);
  border-radius: 3px;
  transition: background 0.2s;
}

.chat-area::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 150, 150, 0.5);
}

/* 消息样式 */
.message {
  display: flex;
  max-width: 85%;
  animation: slideIn 0.3s ease;
}

.message-system {
  align-self: center;
  margin: 8px 0;
}

.message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-bottom: 20px;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-content {
  padding: 10px 14px;
  border-radius: 8px;
  margin: 0 10px;
  max-width: calc(100% - 46px);
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-system .message-content {
  background-color: #e9e9eb;
  color: #666;
  font-size: 12px;
  padding: 6px 12px;
}

.message-user .message-content {
  background: var(--gradient);
  color: white;
  border-bottom-right-radius: 4px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.message-service .message-content {
  background-color: white;
  color: #333;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
}

.message-time {
  position: absolute;
  bottom: -20px;
  font-size: 10px;
  color: #999;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}

.message:hover .message-time {
  opacity: 1;
}

.message-user .message-time {
  right: 0;
}

.message-service .message-time {
  left: 0;
}

/* 打字中提示 */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background-color: white;
  border-radius: 16px;
  align-self: flex-start;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background-color: var(--primary-color);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

/* 输入区域 */
.input-area {
  padding: 12px;
  border-top: 1px solid #eee;
  background-color: white;
  position: relative;
}

.message-input {
  width: 100%;
  border-radius: 30px !important;
  padding: 8px 16px !important;
  border: 1px solid #EEEEEE!important;
  background-color:#EEEEEE !important;
  transition: all 0.2s;
  resize: none;
  font-family: inherit;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.message-input:focus {
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2) !important;
  transform: scale(1.01);
}

.input-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.emoji-btn {
  width: 50px;
  height: 36px;
}
.send-btn {
  width: 120px;
  height: 36px;
}
.emoji-btn,
.send-btn {
  background: var(--gradient);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.emoji-btn:hover,
.send-btn:hover:not(:disabled) {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.send-btn:disabled {
  background-color: #dcdfe6;
  cursor: not-allowed;
  box-shadow: none;
}

/* 表情选择器 */
.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 8px;
  border: 1px solid #eee;
}

.emoji-item {
  font-size: 20px;
  cursor: pointer;
  text-align: center;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.emoji-item:hover,
.emoji-item-hover {
  background-color: rgba(64, 158, 255, 0.1);
  transform: scale(1.2);
  border: 1px solid var(--primary-color);
}

/* 快捷操作按钮 */
.quick-actions {
  position: absolute;
  bottom: 20px;
  right: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  background-color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: #666;
  animation: actionBtnPopUp 0.3s ease-out;
}

.action-btn:hover {
  background: var(--gradient);
  color: white;
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 动画效果 */
@keyframes float {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInTop {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounceIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes typing {
  0% {
    transform: translateY(0px);
  }
  28% {
    transform: translateY(-5px);
  }
  44% {
    transform: translateY(0px);
  }
}

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
  100% {
    opacity: 1;
  }
}

@keyframes avatarPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

@keyframes windowSlideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes actionBtnPopUp {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* 适配左侧定位 */
::v-deep .kanban-girl-cs:not([style*="left:"]) {
  flex-direction: row-reverse;
}

::v-deep .kanban-girl-cs[style*="left:"] {
  flex-direction: row;
}

::v-deep .kanban-girl-cs[style*="left:"] .chat-window {
  margin-right: 0;
  margin-left: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .kanban-girl-cs {
    --character-height: 200px;
    --character-width: 100px;
  }

  .character-img {
    max-height: var(--character-height);
    max-width: var(--character-width);
  }

  .chat-window {
    width: calc(100vw - 40px) !important;
    height: 80vh !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
  }

  .quick-actions {
    right: 120px !important;
  }

  .action-btn {
    width: 32px;
    height: 32px;
  }
}
</style>
